#include "Semaphore.h"


Semaphore::Semaphore(void)
{
    sem_init(&m_sem, 0, 0);
}

Semaphore::Semaphore(unsigned int nValue)
{
    sem_init(&m_sem, 0, nValue);
}

Semaphore::Semaphore(bool bShared, unsigned int nValue)
{
    int nShared;

    if (bShared)
        nShared = 1;
    else
        nShared = 0;

    sem_init(&m_sem, nShared, nValue);
}

Semaphore::~Semaphore(void)
{
    sem_destroy(&m_sem);
}

int Semaphore::Post()
{
    sem_post(&m_sem);
}

int Semaphore::TryWait()
{
    sem_trywait(&m_sem);
}

int Semaphore::Wait()
{
    sem_wait(&m_sem);
}





